package ws.very.common.web.com
import scala.util._

trait CaptchaBiz {
  type MobileInfo
  type Code = S

  protected def captchaCode = Random.nextInt(99999).toString

  protected def sendCaptcha(mobileInfo: MobileInfo)(handleCode: S => Unit) = {
    val code = captchaCode
    handleCode(code)
    sendCaptchaSms(mobileInfo)(code)
  }

  protected def sendCaptchaSms(mobileInfo: MobileInfo)(code: S): O[S]

}